Add compressor options#335
Conversation
This allows specifying Terser options in mangle.json or package.json's "mangle" field.
|
I've updated the PR with a new config format. The previous Now, in either {
// "minify" for Terser (https://github.com/terser-js/terser#minify-options-structure)
// Note: works as a key in both package.json or mangle.json
"minify": {
// Legacy/convenient way to set mangle.properties.{regex,reserved}:
"properties": "^_",
"reserved": ["_dom", "_constructor"],
// Optionally specify Terser compress configuration.
// Supported values: https://github.com/terser-js/terser#compress-options
"compress": {
"hoist_vars": true,
"reduce_funcs": false
},
// Optionally specify Terser mangle configuration
// Supported values: https://github.com/terser-js/terser#mangle-options
"mangle": {}
}
} |
marvinhagemeister
left a comment
There was a problem hiding this comment.
LGTM 🎉👍 I always wondered why we didn't just expose the whole terser config.
|
@marvinhagemeister for now I've left out a couple top-level configuration items like |
hassanbazzi
left a comment
There was a problem hiding this comment.
Was gonna ask the same as Marvin but makes sense I guess. Can't you just spread the rest of the config onto Terser instead? If someone passes something specific (without it being documented), that means they want something very specific and they know (I think) what they're doing.
So we document and expose exactly what we want people to actually change, and spread the rest just in case.
|
@hassanbazzi most of the Terser options folks would want to change are on For Terser's root options, we really can't allow arbitrary customization. Doing so would break output |
This allows specifying Terser options in mangle.json or package.json. The old
"mangle"field is still supported for legacy reasons alongside the new"minify"option.This is useful for projects that are already structured with functions aimed at gzip compression optimization.